/**
 * Description: RegisterLargeItemServiceImpl.java
 * Copyright (c) 2008-2009  Neo. 
 * All Rights Reserved.
 * @Version1.0 2010-03-09 李韦 created
 */
package org.paradise.dms.services.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.paradise.dms.dao.impl.SwipcardDAOImpl;
import org.paradise.dms.pojo.Swipcard;
import org.paradise.dms.services.SwipcardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.dheaven.framework.dao.DaoException;

/**
 * Description: Copyright (c) 2008-2009 Neo. All Rights Reserved.
 * 
 * @Version1.0 2010-03-09 李韦 created
 */
@Service
public class SwipcardServiceImpl implements SwipcardService {
	private static Logger log = Logger
			.getLogger(SwipcardServiceImpl.class);
	@Autowired
	@Qualifier("swipcardDAOImpl")
	private SwipcardDAOImpl swipcardDAOImpl;
	List<Swipcard> swiplist;



	public SwipcardDAOImpl getSwipcardDAOImpl() {
		return swipcardDAOImpl;
	}

	public void setSwipcardDAOImpl(SwipcardDAOImpl swipcardDAOImpl) {
		this.swipcardDAOImpl = swipcardDAOImpl;
	}

	public List<Swipcard> getSwiplist() {
		return swiplist;
	}

	public void setSwiplist(List<Swipcard> swiplist) {
		this.swiplist = swiplist;
	}

	/**
	 * 
	 * Description: 增加一条刷卡记录信息
	 * 
	 * @Version1.0  2010-03-09 李韦 created
	 * @param swipcard
	 * @throws DaoException
	 */
	public boolean insertSwipcard(Swipcard swipcard) throws DaoException {
		
		
			try {
				this.swipcardDAOImpl.insertSwipcard(swipcard);
				log.info("DMS_info_刷卡记录存储成功");
				return true;
			} catch (Exception e) {
				log.error("DMS_info_刷卡记录存储失败" );
				e.printStackTrace();
				return false;
			}
		
	}
	
	/**
	 * 
	 * Description: 删除一条刷卡记录
	 * 
	 * @Version1.0 2010-03-09 李韦 created
	 * @param swipcardid
	 * @return
	 */
	public boolean deleteSwipcard(int swipcardid) {
		try {
			this.swipcardDAOImpl.deleteSwipcard(swipcardid);
			log.info("DMS_info_单条刷卡记录删除成功");
			return true;
		} catch (Exception e) {
			log.error("DMS_info_单条刷卡记录删除失败" );
			e.printStackTrace();
			return false;
		}
	}
	
	/**
	 * 
	 * Description: 取得一条刷卡记录
	 * 
	 * @Version1.0 2010-03-09 李韦 created
	 * @param swipcardid
	 *            刷卡记录的ID值
	 * @return
	 * @throws DaoException
	 */
	@SuppressWarnings("unchecked")
	public List<Swipcard> getSwipcard(int swipcardid)
			throws DaoException {
		try {
			swiplist = this.swipcardDAOImpl.getSwipcard(swipcardid);
			log.info("DMS_info_单条刷卡记录读取成功");
			return swiplist;
		} catch (Exception e) {
			log.error("DMS_info_单条刷卡记录读取失败" );
			e.printStackTrace();
			return null;
		}
		
	}


	/**
	 * 
	 * Description: 取得所有刷卡记录
	 * 
	 * @Version1.0 2010-03-09 李韦 created
	 * @return
	 * @throws DaoException
	 */

	@SuppressWarnings("unchecked")
	public List<Swipcard> getSwipcards(String hostname) throws DaoException {
		try {
			swiplist = this.swipcardDAOImpl.getSwipcards(hostname);
			log.info("DMS_info_前十条刷卡记录读取成功");
			return swiplist;
		} catch (Exception e) {
			log.error("DMS_info_前十条刷卡记录读取失败" );
			e.printStackTrace();
			return null;
		}
	}
}
